#ifndef TRANSISTOR_H
#define TRANSISTOR_H

#include <QGraphicsItem>
#include <QtCore>
#include <QtWidgets>
#include "rules.h"
#include "metal.h"

class Transistor : public QGraphicsItem
{
    friend class MainWindow;
    friend class Cell;
    friend class Data;
    friend class Placement;
    friend class Routing;
    friend class Routing1;
    friend class Routing2;
    friend class TAPlacement;

public:
    explicit Transistor();

    void setTransistorName(QString name);
    void setSourceNetName(QString name);
    void setGateNetName(QString name);
    void setDrainNetName(QString name);
    void setBulkNetName(QString name);
    void setTransistorType(QString name);
    void setPosIndex(int i);
    void setW(qreal w);
    void setL(qreal l);
    void removeLeftContact();
    void removeRightContact();
    QPointF getSourceContPos();
    QPointF getDrainContPos();
    int getPosIndex();
    QPointF getGatePos();
    QRectF getSourceDiffWithM1Intersection(Metal* m1);
    QRectF getDrainDiffWithM1Intersection(Metal* m1);

    Metal* getGateRect();
    Metal* getDiffRect();

    bool drawNetNames;

    void resetContacts();

    QString gateNetName;
    int posIndex;

private:
    qreal w;
    qreal l;


    int defaultPosIndex;

    QString transistorType;
    QString sourceNetName;
    QString drainNetName;

    QString bulkNetName;
    QString transistorName;

    bool flipped;
    bool routedWithPo;
    bool routed;

    qreal *scale;

    QRectF gateRect;
    QRectF diffRect;
    QRectF leftContRect;
    QRectF rightContRect;

    QPointF routedPos;

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QRectF boundingRect() const;

    void printDiffCifFormat(QTextStream *out);
    void printPoCifFormat(QTextStream *out);
signals:
    
public slots:
    
};

#endif // TRANSISTOR_H
